"""
_*_ : utf-8 _*_ 
@Time: 2023/11/1 21:39
@Author: LWK
@File: 064_urllib_异常
@Project: demo01
"""
import urllib.request
import urllib.error

# 错误的一个请求地址imerrorurl
url = 'https://blog.csdn.net/m0_65639340/article/details/126261176imerrorurl'
#url = 'https://www.gousheng222.tv'

headers = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) '
                  'Chrome/118.0.0.0 Safari/537.36 Edg/118.0.2088.76'
}

try:
    req = urllib.request.Request(url=url, headers=headers)
    res = urllib.request.urlopen(req)
    content = res.read().decode('utf-8')
    print(content)
except urllib.error.HTTPError:
    print('系统正在升级。。。')
except urllib.error.URLError:
    print('真的在升级。。。')